﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QuantitativeInvestment.Bean;
using QuantitativeInvestment.Tools;

namespace QuantitativeInvestment.Factor
{
    class KamaFactor:Factor
    {
        public KamaFactor()
        {
            this.name = "考夫曼自适应增均线";
            Parameter p = new Parameter("天数",30);
            this.paraList.Add(p.name,p);
        }
        public override void addFactorValue(Stock stock)
        {
            int num = Int32.Parse(this.paraList["天数"].value.ToString());

            if (!stock.factors.ContainsKey(this.name + this.paraList["天数"].value.ToString()))
            {
                TaLib lib = new TaLib();

                double[] kamaValues = lib.getKama(stock.factors["收盘价"],num);
                int length = stock.factors["收盘价"].Length;

                stock.factors.Add(this.name + this.paraList["天数"].value.ToString() + "考夫曼自适应增均线:", kamaValues);

                }
        }
    }
}
